/*
ID: guoxu1
PROG: beads
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
using namespace std;

#define cin fin
#define cout fout

int main()
{
	ifstream fin( "beads.in" );
	ofstream fout( "beads.out" );

	string str;
	getline( cin, str );
	getline( cin, str );
	int count = str.size();
	str += str;

	int max = -1;
	for( int i = 0; i < count; i++ )
	{
		const char* p = str.c_str() + i;
		int l = 1;
		char c = p[l - 1];
		while( c == 'w' || c == p[l] || 'w' == p[l] )
		{
			if( p[l] != 'w' ) c = p[l];
			if( l + 1 > count ) break;
			l++;
		}

		int r = 0;
		if( l < count )
		{
			r = 1;
			c = p[count - r];
			while( c == 'w' || c == p[count - r - 1] || 'w' == p[count - r - 1] )
			{
				if( p[count - r - 1] != 'w' ) c = p[count - r - 1];
				if( r + l + 1 > count ) break;
				r++;
			}
		}

		if( max < l + r )
		{
			max = l + r;
		}
	}
	cout << max << endl;

	return 0;
}
